package com.kele.controller;

import com.kele.domain.Blog;
import com.kele.domain.ThumbsUp;
import com.kele.service.BlogService;
import com.kele.service.ThumbsUpService;
import com.kele.utils.ResponseData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class JudgeThumbsUpController {
    @Resource
    ThumbsUpService thumbsUpService;
    @Resource
    BlogService blogService;

    @RequestMapping("/judge")
    @ResponseBody
    public ResponseData judgeThumbsUp(int blogid, int userid){
       ThumbsUp ts =thumbsUpService.findThumbsUp(blogid, userid);
       Blog blog=blogService.findBlogById(blogid);
       if(ts!=null){
           return ResponseData.success("1",blog.getThumbsup());
       }else{
           return ResponseData.success("0",blog.getThumbsup());
       }
    }

}
